//package cn.smbms.servlet.user;
//
//import cn.smbms.pojo.User;
//import cn.smbms.service.user.UserService;
//import cn.smbms.tools.Constants;
//import org.springframework.context.ApplicationContext;
//import org.springframework.context.support.FileSystemXmlApplicationContext;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//public class LoginServlet extends HttpServlet {
//
//	/**
//	 * Constructor of the object.
//	 */
//	public LoginServlet() {
//		super();
//	}
//
//	/**
//	 * Destruction of the servlet. <br>
//	 */
//	public void destroy() {
//		super.destroy(); // Just puts "destroy" string in log
//		// Put your code here
//	}
//
//	/**
//	 * The doGet method of the servlet. <br>
//	 *
//	 * This method is called when a form has its tag value method equals to get.
//	 *
//	 * @param request the request send by the client to the server
//	 * @param response the response send by the server to the client
//	 * @throws ServletException if an error occurred
//	 * @throws IOException if an error occurred
//	 */
//	public void doGet(HttpServletRequest request, HttpServletResponse response)
//			throws ServletException, IOException {
//
//	}
//
//	/**
//	 * The doPost method of the servlet. <br>
//	 *
//	 * This method is called when a form has its tag value method equals to post.
//	 *
//	 * @param request the request send by the client to the server
//	 * @param response the response send by the server to the client
//	 * @throws ServletException if an error occurred
//	 * @throws IOException if an error occurred
//	 */
//
//	public void doPost(HttpServletRequest request, HttpServletResponse response)
//			throws ServletException, IOException {
//		//ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
//		ApplicationContext context=new FileSystemXmlApplicationContext("classpath:applicationContext.xml");
//		UserService userService=context.getBean("user", UserService.class);
//		System.out.println("login ============ " );
//		//获取用户名和密码
//		String userCode = request.getParameter("userCode");
//		String userPassword = request.getParameter("userPassword");
//		//调用service方法，进行用户匹配
//		//UserService userService = new UserServiceImpl();
//		User user = userService.login(userCode,userPassword);
//		if(null != user){//登录成功
//			//放入session
//			request.getSession().setAttribute(Constants.USER_SESSION, user);
//			//页面跳转（frame.jsp）
//			response.sendRedirect("jsp/frame.jsp");
//		}else{
//			//页面跳转（login.jsp）带出提示信息--转发
//			request.setAttribute("error", "用户名或密码不正确");
//			request.getRequestDispatcher("login.jsp").forward(request, response);
//		}
//	}
//
//	/**
//	 * Initialization of the servlet. <br>
//	 *
//	 * @throws ServletException if an error occurs
//	 */
//	public void init() throws ServletException {
//		// Put your code here
//	}
//
//}
